package com.xxx.kjds;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author MSI-NB
 * @date 2022/6/13 13:58
 */

public class MySqlGenerator {
    public void generator() throws Exception {
        List<String> warnings = new ArrayList<>();
        File config = new File("src/main/resources/generatorConfig.xml");
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration configuration = cp.parseConfiguration(config);
        DefaultShellCallback callback = new DefaultShellCallback(true);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(configuration, callback, warnings);
        myBatisGenerator.generate(null);
    }

//    public static void main(String[] args) throws Exception {
//        try {
//            MySqlGenerator generator = new MySqlGenerator();
//            generator.generator();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
}
